package com.xiaoma.juc;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

class CompletableFutureTest {

  public static void main(String[] args) {
    AtomicInteger atomicInteger = new AtomicInteger(1);
    ExecutorService executorService = Executors.newFixedThreadPool(10, r -> {
      Thread thread = new Thread(r);
      thread.setName("cdz_" + atomicInteger.getAndIncrement());
      return thread;
    });

    CompletableFuture
        .supplyAsync(() -> aa())
        .thenApply(result -> result.toUpperCase())
        .thenAccept(result -> {
          System.out.println(Thread.currentThread().getName());
          System.out.println(result);
    });

    executorService.shutdownNow();


  }

  private static String aa() {
    return "aaa";
  }

}
